package trace

import (
	"strings"
)

type TextArrayMapCarrier map[string][]string

func (w TextArrayMapCarrier) Set(key, val string) {
	key = strings.ToLower(key)
	w[key] = append(w[key], val)
}

func (w TextArrayMapCarrier) ForeachKey(handler func(key, val string) error) error {
	for k, vals := range w {
		for _, v := range vals {
			if err := handler(k, v); err != nil {
				return err
			}
		}
	}

	return nil
}
